﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using nplJobsCommon.JobSeeker;
using System.Data.SqlClient;
namespace nplJobsDAL.Select
{
    
    public class SelectJobSeekerSkills:DataAccessBase
    {
        string procedureName = "spSelectJobSeekerSkills";
        public Guid JobSeekerID { get; set; }

        #region GetJobSeekerSkills
        public List<JobSeekerSkills> GetJobSeekerSkills()
        {
            DataBaseHelper dbHelper;
            DataSet dsJobSeekerSkills;

            try
            {                
                dbHelper = new DataBaseHelper(procedureName);
                
                SqlParameter sqp = new SqlParameter();
                sqp.DbType = DbType.Guid;
                sqp.Value = JobSeekerID;
                SqlParameter[] prm = { sqp };
                dbHelper.Parameters = prm;
                dsJobSeekerSkills = dbHelper.Run(base.ConnectionString, dbHelper.Parameters);
                return GetList(dsJobSeekerSkills);
            }
            catch (Exception)
            {
                throw;
            }
        }
        #endregion

        #region GetList
        private List<JobSeekerSkills> GetList(DataSet dsJobSeekerSkills)
        {
            List<JobSeekerSkills> jobSeekerSkills;
            try
            {

                jobSeekerSkills = (from n in dsJobSeekerSkills.Tables[0].AsEnumerable()
                                                select new JobSeekerSkills
                                                {                                                    
                                                    JobSeekerID = n.Field<Guid>("JobSeekerID"),
                                                    skillsID = n.Field<Int64>("skillsID"),
                                                    experience = n.Field<int>("experience"),
                                                    skillsDescription = n.Field<string>("skillsDescription")
                                                }).ToList();

                return jobSeekerSkills;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message.ToString());
            }
            finally { }
        }
        #endregion

    }
}
